package com.chuangjiangx.member.basic.ddd.domain.service;

import com.chuangjiangx.commons.exception.BaseException;
import com.chuangjiangx.member.score.ddd.dal.mapper.MbrScoreStreamDalMapper;
import com.chuangjiangx.member.basic.ddd.domain.model.MemberId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author cj-ch
 * @date 2018/3/13 下午8:44
 */
@Service
public class MemberScoreService {

    @Autowired
    private MbrScoreStreamDalMapper mbrScoreStreamDalMapper;

    /**
     * 转移积分
     * @param sourceMember
     * @param targerMember
     */
    public void transfer(MemberId sourceMember, MemberId targerMember){
        if(Objects.isNull(sourceMember) || Objects.isNull(targerMember)){
            throw new BaseException("","会员Id不能为空!");
        }
        mbrScoreStreamDalMapper.transfer(sourceMember.getId(),targerMember.getId());
    }
}
